import {navigate} from "../../history";
import PropTypes from 'prop-types';
import {Children, cloneElement} from "react";

function Link({to , children}) {
  return cloneElement(Children.only(children),{
    onClick: () => navigate(to)
  });
}

Link.propTypes = {
  to: PropTypes.string,
  children: PropTypes.node,
}

export default Link;
